import asyncio
import sys
from typing import Any, Coroutine, TypeVar

_T = TypeVar("_T")


def get_event_loop(func: Coroutine[Any, Any, _T], debug: bool = False) -> _T:
    # uvloop is unsupported for windows
    if sys.platform != "win32":
        import uvloop

        return uvloop.run(func, debug=debug)
    else:
        return asyncio.run(func, debug=debug)
